﻿#region Using Statements
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using System.Collections.Generic;
using System;
using Microsoft.Xna.Framework.Input;
#endregion

namespace pigs
{
    /// <summary>
    /// The options screen is brought up over the top of the main menu
    /// screen, and gives the user a chance to configure the game
    /// in various hopefully useful ways.
    /// </summary>
    class AchievScreen : MenuScreen
    {

        ContentManager content;
        SpriteFont font;
        SpriteFont afont;
        Achievments a;

        /// <summary>
        /// Constructor.
        /// </summary>
        public AchievScreen(ScreenManager screen, Achievments achiev)
            : base("Achievements")
        {
            a = achiev;

            MenuEntry back = new MenuEntry("Back");
            back.Position = new Vector2(screen.GraphicsDevice.Viewport.Width / 2, 800);
            back.Selected += OnCancel;

            MenuEntries.Add(back);
        }

        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");

            this.font = content.Load<SpriteFont>("fonts/menufont");
            this.afont = content.Load<SpriteFont>("fonts/acheivmentFont");

            setPositions();
        }

        public void setPositions()
        {
            Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
            a.cityNoEscape.position = new Vector2(viewport.Width / 2 - 450 - 50, 200);
            a.cityAim.position = new Vector2(viewport.Width / 2 - 450 - 50, 375);
            a.cityNoHits.position = new Vector2(viewport.Width / 2 - 450 - 50, 550);

            a.skNoEscape.position = new Vector2(viewport.Width / 2 - 150 - 50, 200);
            a.skAim.position = new Vector2(viewport.Width / 2 - 150 - 50, 375);
            a.skNoHits.position = new Vector2(viewport.Width / 2 - 150 - 50, 550);

            a.bcNoEscape.position = new Vector2(viewport.Width / 2 + 150 - 50, 200);
            a.bcAim.position = new Vector2(viewport.Width / 2 + 150 - 50, 375);
            a.bcNoHits.position = new Vector2(viewport.Width / 2 + 150 - 50, 550);

            a.sur25.position = new Vector2(viewport.Width / 2 + 450 - 50, 200);
            a.sur50.position = new Vector2(viewport.Width / 2 + 450 - 50, 375);
            a.sur100.position = new Vector2(viewport.Width / 2 + 450 - 50, 550);
        }

        /// <summary>
        /// Draws the loading screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {

            base.Draw(gameTime);

            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            Color color = Color.White * TransitionAlpha * TransitionAlpha;

            // Draw the text.
            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied);

            a.cityNoHits.Draw(spriteBatch, color, afont, false);
            a.cityAim.Draw(spriteBatch, color, afont, false);
            a.cityNoEscape.Draw(spriteBatch, color, afont, false);

            a.bcNoHits.Draw(spriteBatch, color, afont, false);
            a.bcAim.Draw(spriteBatch, color, afont, false);
            a.bcNoEscape.Draw(spriteBatch, color, afont, false);

            a.skNoHits.Draw(spriteBatch, color, afont, false);
            a.skAim.Draw(spriteBatch, color, afont, false);
            a.skNoEscape.Draw(spriteBatch, color, afont, false);

            a.sur25.Draw(spriteBatch, color, afont, false);
            a.sur50.Draw(spriteBatch, color, afont, false);
            a.sur100.Draw(spriteBatch, color, afont, false);

            spriteBatch.End();
        }
    }
}
